<?php if(!defined('SABLOG_ROOT')) exit('Access Denied');?>

<div id="submenu">
  <ul>
    <li><a href="cp.php?job=caselib&action=add"
      <!--{if $action == 'add'}-->
      class="focus"
      <!--{/if}-->
      ><span>添加案例</span></a></li>
    <!--{if $action == 'mod'}-->
    <li><a href="cp.php?job=caselib&action=mod&caseid=$case[caseid]"
      <!--{if $action == 'mod'}-->
      class="focus"
      <!--{/if}-->
      ><span>修改案例</span></a></li>
    <!--{/if}-->
    <li><a href="cp.php?job=caselib&action=list"
      <!--{if $action == 'list'}-->
      class="focus"
      <!--{/if}-->
      ><span>管理案例</span></a></li>
  </ul>
</div>

<div id="wrap">
<script type="text/javascript">
function really(d,m,n) {
	if (confirm(m)) {
		window.location.href='cp.php?job=comment&action=delonelog&trackbacklogid='+n+'&caselibid='+d;
	}
}
function popnew(url,title,width,height){
	var w = 1024;
	var h = 768;
	if (document.all || document.layers){
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var leftPos = (w/2-width/2);
	var topPos = (h/2-height/2);
	window.open(url,title,"width="+width+",height="+height+",top="+topPos+",left="+leftPos+",scrollbars=no,resizable=no,status=no");
}
function checkform() {
	if ($('title') && $('title').value == "") {
		alert("请输入标题.");
		return false;
	}
	$('submit').disabled = true;
	return true;
}
var dirurl = '$dirurl';
</script>
<!--{if $action == 'list'}-->
<h2>{$subnav}&raquo;</h2>
<table border="0" cellspacing="0" cellpadding="0">
  <form method="post" action="cp.php?job=caselib&action=list">
    <tr class="tablecell2">
      <td>分类:<br />
        <select name="cid">
          <option value="">== 全部分类 ==</option>
          <!--{loop $catedb $cateid $name}-->
          <option value="$cateid"
          <!--{if $cateid == $cid}-->
          selected
          <!--{/if}-->
          >$name
          </option>
          <!--{/loop}-->
        </select>
      </td>
      <td>月份:<br />
        <select name="m">
          <option value="">== 任何时间 ==</option>
          <!--{loop $archivecache $key $data}-->
          <option value="$key"
          <!--{if $key == $m}-->
          selected
          <!--{/if}-->
          >$key
          </option>
          <!--{/loop}-->
        </select>
      </td>
      <td>状态:<br />
        <select name="view">
          <option value="">== 全部 ==</option>
          <option value="display"
          <!--{if $view == 'display'}-->
          selected
          <!--{/if}-->
          >显示的
          </option>
          <option value="hidden"
          <!--{if $view == 'hidden'}-->
          selected
          <!--{/if}-->
          >隐藏的
          </option>
          <option value="stick"
          <!--{if $view == 'stick'}-->
          selected
          <!--{/if}-->
          >置顶的
          </option>
        </select>
      </td>
      <td>关键字:<br />
        <input class="formfield" type="text" name="keywords" size="20" maxlength="30" value="$keywords" />
      </td>
      <td colspan="2" align="center" class="tablecell"><input type="hidden" name="action" value="list" />
        <input type="hidden" name="do" value="search" />
        <button type="submit">过滤</button></td>
    </tr>
  </form>
</table>
<form method="post" action="cp.php?job=caselib" name="form1">
  <table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
    <tr class="tdbheader">
      <td width="7%">显示</td>
      <td width="45%">标题</td>
      <td width="10%">学校</td>
      <td width="15%" nowrap>时间</td>
      <td width="10%" nowrap>下载次数</td>
      <td width="6%" nowrap>权限</td>
      <td width="4%" nowrap><input name="chkall" value="on" type="checkbox" onclick="checkall(this.form)" /></td>
    </tr>
    <!--{loop $casedb $case}-->
    <!--{eval $thisbg = isset($thisbg) && $thisbg == 'tablecell' ? 'tablecell2' : 'tablecell';}-->
    <tr class="$thisbg" onmouseover="this.className='cellfocus';" onmouseout="this.className='$thisbg';">
      <td><a href="cp.php?job=caselib&action=visible&caselibid=$case[caseid]"><!--{if $case['visible']}--><span class="yes">显示</span><!--{else}--><span class="no">隐藏</span><!--{/if}--></a>
      </td>
      <td nowrap>
        <!--{if $case['stick']}-->
        [置顶]
        <!--{/if}-->
        <a href="cp.php?job=caselib&action=mod&caseid=$case[caseid]">$case[title]</a>
      </td>
      <td nowrap><a href="#">&nbsp;</a></td>
      <td nowrap>$case[dateline]</td>
      <td nowrap>$case[downloads]</td>
      <td nowrap>$case[permission]</td>
      <td nowrap><input type="checkbox" name="caselib[]" value="$case[caseid]" /></td>
    </tr>
    <!--{/loop}-->
    <tr class="tablecell">
      <td colspan="8" nowrap="nowrap"><div class="records">记录:$total</div>
        <div class="multipage">$multipage</div></td>
    </tr>
  </table>
  <table cellpadding="0" cellspacing="0" border="0" align="center" width="100%" height="40">
    <tr>
      <td align="right">
		<select name="do">
            <option value="">= 管理操作 =</option>
            <option value="stick">置顶</option>
            <option value="unstick">取消置顶</option>
            <option value="hidden">设置隐藏</option>
            <option value="display">设置可见</option>
            <option value="delete">删除</option>
            <option value="move">移动</option>
        </select>
		<button type="submit">确定</button>
          <input type="hidden" name="action" value="domore">
	  </td>
    </tr>
  </table>
</form>
<!--{elseif in_array($action, array('add', 'mod'))}-->
<h2>{$tdtitle}&raquo;</h2>
$tag_js
<form action="cp.php?job=caselib" enctype="multipart/form-data" method="POST" name="form1" onsubmit="return checkform();">
  <table width="100%" border="0" cellspacing="5" cellpadding="0">
    <tr>
      <td width="70%" valign="top">
		  <div class="dashboard-element">
			  <h3>
				<!--{if $case['comments']}-->
					<span style="float:right">上传者:<a href="cp.php?job=caselib&action=list&uid=$case[uid]">$case[username]</a></span>
				<!--{/if}-->
				案例标题
			  </h3>
			  <div class="element-info">
				<input type="text" class="formfield" name="title" style="width:700px" value="$case[title]" />
			  </div>
		  </div>
		  <div class="dashboard-element">
			<h3>案例简介</h3>
			  <div class="element-info">
			    <textarea class="formfield" name="description" style="width:700px" >$case[description]</textarea>
			  </div>
		  </div>
          
		  <!--{if $action == 'add'}-->
		  <div class="dashboard-element">
			<h3>大学名称</h3>
			  <div class="element-info">
				<input id="keywords" class="formfield" autocomplete="off" type="text" name="university" size="70" maxlength="20" value="$case[university]" onfocus="simple_ac_init('keywords', 'taghint')"/>
				<br />
				<span id="taghint">$showtaglist</span>
				<br />
				<div class="element-desc">在这里输入参赛学校的名称</div>
			  </div>
		  </div>
          <!--{/if}-->


		  <div class="dashboard-element">
			<h3>标签(关键字)</h3>
			  <div class="element-info">
				<input id="keywords" class="formfield" autocomplete="off" type="text" name="keywords" size="70" maxlength="110" value="$case[keywords]" onfocus="simple_ac_init('keywords', 'taghint')"/>
				<img src="$options[url]templates/admin/images/insert.gif" alt="插入已经使用的Tag" onclick="popnew('cp.php?job=category&action=getalltags','tag',450,570)" style="cursor:pointer" />
				<br />
				<span id="taghint">$showtaglist</span>
				<br />
				<div class="element-desc"><!--{if $action == 'mod'}-->大学名称已作为第一个关键词<br /><!--{/if}-->用“,”分隔多个关键字, 最多允许添加5个关键字, 每个关键字不能超过30个字符.</div>
			  </div>
		  </div>


		<!--{if $attachdb}-->
		  <div class="dashboard-element">
			<h3>已上传附件</h3>
			  <div class="element-info">
					<div class="element-desc">
						<input type="checkbox" name="keep[]" value="$attach[attachmentid]" checked /> 保留
						<a href="attachment.php?id=$attach[attachmentid]" target="_blank"><b>$attach[filename]</b></a> ($attach[dateline], $attach[filesize]) <b>
					</div>
			  </div>
		  </div>
		<!--{/if}-->

		  <div class="dashboard-element">
			<h3>上传新附件</h3>
			  <div class="element-info">
				<table cellspacing="0" cellpadding="0" border="0">
				  <tbody id="attachbodyhidden" style="display:none"><tr>
					  <td>
                      	<input type="file" name="attach[]" class="formfield" />
						<span id="localfile[]"></span>
						<input type="hidden" name="localid[]" /></td>
					</tr></tbody>
				  <tbody id="attachbody"></tbody>
				</table>
				<script type="text/javascript" src="$options[url]include/jscript/attachment.js"></script>
				  <div class="element-desc">图片超过2M缩略图和水印均不生效.如果上传大于2M的图片请自行处理.</div>
			  </div>
		  </div>

	  </td>
      <td width="30%" style="padding-left:5px;" valign="top">
		  <!--<div class="dashboard-element">
			<h3>案例分类</h3>
			  <div class="element-info">
				<select name="cid" id="cid">
				  <option value="">== 选择分类 ==</option>
				  <!--{loop $catedb $cid $name}-->
				  <option value="$cid" <!--{if $cid == $case['cid']}-->selected<!--{/if}-->>$name</option>
				  <!--{/loop}-->
				</select>
			  </div>
		  </div>-->

		  <div class="dashboard-element">
			<h3>高级选项(开发中,尚且无用)</h3>
			  <div class="element-info">
				<label for="closecomment">
				<input id="closecomment" name="closecomment" type="checkbox" value="1" $closecomment_check />
				禁止下载</label>
				<br />
				<label for="visible">
				<input id="visible" name="visible" type="checkbox" value="1" $visible_check />
				显示本文</label>
				<br />
			  </div>
		  </div>

		  <div class="dashboard-element">
			<h3>自定义发布时间</h3>
			  <div class="element-info">

				<input class="formfield" name="newyear" type="text" value="$newyear" maxlength="4" style="width:30px" />
				年
				<input class="formfield" name="newmonth" type="text" value="$newmonth" maxlength="2" style="width:15px" />
				月
				<input class="formfield" name="newday" type="text" value="$newday" maxlength="2" style="width:15px" />
				日<br />
				<input class="formfield" name="newhour" type="text" value="$newhour" maxlength="2" style="width:15px" />
				时
				<input class="formfield" name="newmin" type="text" value="$newmin" maxlength="2" style="width:15px" />
				分
				<input class="formfield" name="newsec" type="text" value="$newsec" maxlength="2" style="width:15px" />
				秒

				  <div class="element-desc"><button type="button" onclick="alert('有效的时间戳典型范围是从格林威治时间 1901 年 12 月 13 日 星期五 20:45:54 到 2038年 1 月 19 日 星期二 03:14:07\\n\\n该日期根据 32 位有符号整数的最小值和最大值而来\\n\\n取值说明: 日取 01 到 30 之间, 时取 0 到 24 之间, 分和秒取 0 到 60 之间!\\n\\n系统会自动检查时间有效性,如果不在有效范围内,将不会执行更改时间操作\\n\\n注意:如果系统是按照时间而不是提交次序排列日志,修改时间可以改变日志的顺序.');">说明</button>
				  <input id="edittime" name="edittime" type="checkbox" value="1" /> 有效?
				</div>
			  </div>
		  </div>

		</td>
    </tr>
  </table>

  <div class="submit">
    <input type="hidden" name="action" value="$act" />
    <input type="hidden" name="caseid" value="$caseid" />
    <input type="hidden" name="oldtags" value="$case[keywords]" />
    <button type="submit">确定</button>
  </div>
</form>
<!--{elseif $_POST['do'] == 'move'}-->
<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
  <form action="cp.php?job=caselib" method="POST">
    <tr class="tdbheader">
      <td colspan="1"><a name="移动日志"></a>移动日志</td>
    </tr>
    <tr>
      <td class="alertbox"><p>
        <ol>
          <br />
          <!--{loop $caselibdb $caselib}-->
          <li><a href="cp.php?job=caselib&action=mod&caselibid=$case[caseid]">$case[title]</a>
            <input type="hidden" name="caselib[]" value="$case[caseid]" />
          </li>
          <!--{/loop}-->
        </ol>
        </p>
        <p>将以上日志移动到
          <select name="cid">
            <option value="" selected>== 选择分类 ==</option>
            <!--{loop $catedb $cid $name}-->
            <option value="$cid">$name</option>
            <!--{/loop}-->
          </select>
        </p>
        <p>
          <button type="submit">确定</button>
        </p>
        <input type="hidden" name="action" value="domove" />
      </td>
    </tr>
  </form>
</table>
<!--{elseif $_POST['do'] == 'delete'}-->
<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
  <form action="cp.php?job=caselib" method="POST">
    <tr class="alertheader">
      <td colspan="1"><a name="删除日志"></a>删除日志</td>
    </tr>
    <tr>
      <td class="alertbox"><p>
        <ol>
          <br />
          <!--{loop $caselibdb $caselib}-->
          <li><a href="cp.php?job=caselib&action=mod&caselibid=$case[caseid]">$case[title]</a>
            <input type="hidden" name="caselib[]" value="$case[caseid]" />
          </li>
          <!--{/loop}-->
        </ol>
        </p>
        <p><b>注意: 删除以上日志将会连同相关评论、引用、附件一起删除，确定吗？</b></p>
        <p>
          <button type="submit">确定</button>
        </p>
        <input type="hidden" name="action" value="dodelete" />
      </td>
    </tr>
  </form>
</table>
<!--{/if}-->
</form>
